##################################################################

# Gautam Nair
# gautam.nair@yale.edu
# Misperceptions of Relative Affluence and Support for International Transfers
# Make Table 1: Study Design and Implementation

##################################################################

rm(list=ls())

library(stargazer)

getwd()
data.working <- readRDS("d_r_cleaned_analysis_dataset.Rda")

groups <- rbind("Control", "Salience: Estimate Rank and Median", "Information: Estimate Rank and Median + Information")
assignment.p <- cbind(rep(0.333, length(groups)))

observed.n <- as.data.frame(table(data.working$group))[,2]
N <- c(rep(sum(observed.n), 3))
observed.prop <- cbind(round(observed.n/N, 3))
working.table <- as.data.frame(cbind(groups, assignment.p, observed.prop, observed.n))
colnames(working.table) <- c("Group", "Projected Assignment Probability", "Actual Assignment Proportion", "N (1559)")
working.table

table.title <- c("Table 1: Study Design and Implementation")
output.file <- c("tf_t_01_design")
stargazer(working.table, 
title = table.title,
out = output.file,
type= "text",
summary=FALSE, 
rownames=FALSE)